package spring.framework.aop.aspectj;

import org.aopalliance.aop.Advice;
import spring.framework.aop.Pointcut;
import spring.framework.aop.PointcutAdvisor;

/**
 * @author fun.pengzh
 * @class spring.framework.aop.aspectj.AspectJExpressionPointcutAdvisor
 * @desc
 * @since 2021-11-25
 */
public class AspectJExpressionPointcutAdvisor implements PointcutAdvisor {

    //切面
    private AspectJExpressionPointcut pointcut;

    //方法
    private Advice advice;

    //表达式
    private String expression;

    public void setExpression(String expression) {
        this.expression = expression;
    }

    @Override
    public Pointcut getPointcut() {
        if (pointcut == null) {
            pointcut = new AspectJExpressionPointcut(expression);
        }
        return pointcut;
    }

    @Override
    public Advice getAdvice() {
        return advice;
    }

    public void setAdvice(Advice advice) {
        this.advice = advice;
    }
}
